{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=3174
  Verdict: Accepted
}
uses SysUtils, Math;
 
const
	firstV:int64=round(1e12);
 
var
	k,kk,ls,cc:int64;
	s:string;
	i:longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
cc:=0;
while not eof do begin
	read(k);
	if k=0 then inc(cc) else write(k,' ');
end;
dec(cc);
for i:=1 to cc do write('0 ');
end.